<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>过渡和动画</title>
    <style>
        *{
            margin-left:0;
            padding:0;
        }
        .box1{
            width:800px;
            height:800px;
            background-color: silver;
            overflow: hidden;
        }
        .box1 div{
            width:100px;
            height:100px;      
        }
        .box2{
            background-color: #bfa;
            /* transition:2s; */
            margin-left: 10px;
            /*过渡  transition
            通过过渡，可以指定当一个属性发生变化时的切换方式
            通过过渡，可以创建一些非常好的效果，提高用户体验*/
            /* transition:all 2s; */
            /*指定要执行过渡的属性*/
            /* transition-property:all; */
            /*过渡效果的持续时间*/
            /* transition-duration: 2s; */
            /*过渡的时序函数，指定过渡的执行方式*/
            /* transition-timing-function: linear; */
            /*加速运动*/
            /* transition-timing-function: ease-in; */
            /* transition-timing-function: cubic-bezier(.24,.95,.82,-0.88); */
            /* transition-timing-function: steps(2,end); */
            /* margin-bottom: 100px; */
            /*设置box2的动画
            animation-name对当前元素生效的关键帧的名字*/
            animation-name:  test;
            /*animation-duration:动画执行时间*/
            animation-duration: 2s;
            animation-timing-function: ease-in-out;
            animation-iteration-count: 4;
            animation-direction: normal;
            animation-play-state: running;
            animation-fill-mode: none;
        }
        .box3{
            background-color:coral;
            transition-property: all;
            transition-duration: 2s;
        }
        .box1:hover div{
            /* width:200px;
            height:200px;
            background-color: chartreuse; */
            margin-left: 700px;
        }
        @keyframes test {
            /*to表示动画开始位置，也可以使用0%*/
            to{
                margin-left:0;
            }
            /*from表示动画结束位置,也可以使用100%*/
            from{
                margin-left: 700px;
            }
            
        }
     
    </style>
</head>
<body>
    <div class="box1">
        <div class="box2"></div>
        <!-- <div class="box3"></div> -->
    </div>
    
</body>
</html>